Namespace pv
The top-level Protovis namespace, pv.
Defined in: pv.js.
Constructor Attributes | Constructor Name and Description |
---|---|
The top-level Protovis namespace.
|
Method Attributes | Method Name and Description |
---|---|
<static> |
pv.blend(arrays)
Given the specified array of arrays, concatenates the arrays into a single
array.
|
<static> |
pv.child()
Returns this.childIndex.
|
<static> |
pv.color(format)
Returns the pv.Color for the specified color format string.
|
<static> |
pv.colors()
Returns a new categorical color encoding using the specified colors.
|
<static> |
pv.cross(a, b)
Given two arrays a and b, returns an array of all possible
pairs of elements [ai, bj].
|
<static> |
pv.dict(keys, f)
Returns a map constructed from the specified keys, using the
function f to compute the value for each key.
|
<static> |
pv.entries(map)
Returns all of the entries (key-value pairs) of the specified object (a
map).
|
<static> |
pv.flatten(map)
Returns a pv.Flatten operator for the specified map.
|
<static> |
pv.hsl(h, s, l, a)
Constructs a new HSL color with the specified values.
|
<static> |
pv.identity(x)
Returns the passed-in argument, x; the identity function.
|
<static> |
pv.index()
Returns this.index.
|
<static> |
pv.keys(map)
Returns all of the property names (keys) of the specified object (a map).
|
<static> |
pv.log(x, b)
Returns the logarithm with a given base value.
|
<static> |
pv.logAdjusted(x, b)
Computes a zero-symmetric logarithm, with adjustment to values between zero
and the logarithm base.
|
<static> |
pv.logCeil(x, b)
Rounds an input value up according to its logarithm.
|
<static> |
pv.logFloor(x, b)
Rounds an input value down according to its logarithm.
|
<static> |
pv.logSymmetric(x, b)
Computes a zero-symmetric logarithm.
|
<static> |
pv.max(array, f)
Returns the maximum value of the specified array.
|
<static> |
pv.mean(array, f)
Returns the arithmetic mean, or average, of the specified array.
|
<static> |
pv.median(array, f)
Returns the median of the specified array.
|
<static> |
pv.min(array, f)
Returns the minimum value of the specified array of numbers.
|
<static> |
pv.naturalOrder(a, b)
The comparator function for natural order.
|
<static> |
pv.nest(array)
Returns a pv.Nest operator for the specified array.
|
<static> |
pv.normalize(array, f)
Returns a normalized copy of the specified array, such that the sum of the
returned elements sum to one.
|
<static> |
pv.numerate(keys, f)
Returns a map from key to index for the specified keys array.
|
<static> |
pv.parent()
Returns this.parent.index.
|
<static> |
pv.permute(array, indexes, f)
Returns a permutation of the specified array, using the specified array of
indexes.
|
<static> |
pv.ramp(start, end)
Returns a linear color ramp from the specified start color to the
specified end color.
|
<static> |
pv.random(min, max, step)
Returns a random number in the range [min, max) that is a
multiple of step.
|
<static> |
pv.range(start, stop, step)
Returns an array of numbers, starting at start, incrementing by
step, until stop is reached.
|
<static> |
pv.repeat(a, n)
Concatenates the specified array with itself n times.
|
<static> |
pv.reverseOrder(a, b)
The comparator function for reverse natural order.
|
<static> |
pv.rgb(r, g, b, a)
Constructs a new RGB color with the specified channel values.
|
<static> |
pv.search(array, value, f)
Searches the specified array of numbers for the specified value using the
binary search algorithm.
|
<static> |
pv.sum(array, f)
Returns the sum of the specified array.
|
<static> |
pv.transpose(arrays)
Given the specified array of arrays, transposes each element
arrayij with arrayji.
|
<static> |
pv.tree(array)
Returns a pv.Tree operator for the specified array.
|
<static> |
pv.values(map)
Returns all of the values (attribute values) of the specified object (a
map).
|
<static> |
pv.vector(x, y)
Returns a pv.Vector for the specified x and y
coordinate.
|
- pv.blend([[1, 2, 3], ["a", "b", "c"]])
- [1, 2, 3].concat(["a", "b", "c"])
- Parameters:
- {array[]} arrays
- an array of arrays.
- Returns:
- {array} an array containing all the elements of each array in arrays.
.fillStyle(pv.Colors.category10().by(pv.child))This method is equivalent to function() this.childIndex, but more succinct.
- See:
- pv.Scale
- pv.Mark#childIndex
- #f00 // #rgb
- #ff0000 // #rrggbb
- rgb(255, 0, 0)
- rgb(100%, 0%, 0%)
- hsl(0, 100%, 50%)
- rgba(0, 0, 255, 0.5)
- hsla(120, 100%, 50%, 1)
If the format argument is already an instance of Color,
the argument is returned with no further processing.
Defined in: Color.js.
- Parameters:
- {string} format
- the color specification string, such as "#f00".
- Returns:
- {pv.Color} the corresponding Color.
pv.colors("red", "green", "blue").by(function(d) d.species)The result of this expression can be used as a fill- or stroke-style property. This assumes that the data's species attribute is a string.
Defined in: Colors.js.
- Parameters:
- {string} colors...
- categorical colors.
- Returns:
- {pv.Scale.ordinal} an ordinal color scale.
- See:
- pv.Scale.ordinal
- Parameters:
- {array} a
- an array.
- {array} b
- an array.
- Returns:
- {array} an array of pairs of elements in a and b.
For example, this expression creates a map from strings to string length:
pv.dict(["one", "three", "seventeen"], function(s) s.length)The returned value is {one: 3, three: 5, seventeen: 9}. Accessor functions can refer to this.index.
- Parameters:
- {array} keys
- an array.
- {function} f
- a value function.
- Returns:
- a map from keys to values.
- Parameters:
- map
- an object.
- Returns:
- {array} an array of key-value pairs corresponding to the keys.
Defined in: Flatten.js.
- Parameters:
- map
- a map to flatten.
- Returns:
- {pv.Flatten} a flatten operator for the specified map.
- See:
- pv.Flatten
Defined in: Color.js.
- Parameters:
- {number} h
- the hue, an integer in [0, 360].
- {number} s
- the saturation, a float in [0, 1].
- {number} l
- the lightness, a float in [0, 1].
- {number} a Optional
- the opacity, a float in [0, 1].
- Returns:
- pv.Color.Hsl
- Parameters:
- x
- a value.
- Returns:
- the value x.
.fillStyle(pv.Colors.category10().by(pv.index))This method is equivalent to function() this.index, but more succinct. Note that the index property is also supported for accessor functions with pv.max, pv.min and other array utility methods.
- See:
- pv.Scale
- pv.Mark#index
- Parameters:
- map
- an object.
- Returns:
- {string[]} an array of strings corresponding to the keys.
- See:
- #entries
- Parameters:
- {number} x
- the number for which to compute the logarithm.
- {number} b
- the base of the logarithm.
- Returns:
- {number} the logarithm value.
- Parameters:
- {number} x
- the number for which to compute the logarithm.
- {number} b
- the base of the logarithm.
- Returns:
- {number} the adjusted, symmetric log value.
- Parameters:
- {number} x
- the number for which to compute the logarithm ceiling.
- {number} b
- the base of the logarithm.
- Returns:
- {number} the rounded-by-logarithm value.
- Parameters:
- {number} x
- the number for which to compute the logarithm floor.
- {number} b
- the base of the logarithm.
- Returns:
- {number} the rounded-by-logarithm value.
- Parameters:
- {number} x
- the number for which to compute the logarithm.
- {number} b
- the base of the logarithm.
- Returns:
- {number} the symmetric log value.
- Parameters:
- {array} array
- an array of objects, or numbers.
- {function} f Optional
- an optional accessor function.
- Returns:
- {number} the maximum value of the specified array.
- Parameters:
- {array} array
- an array of objects, or numbers.
- {function} f Optional
- an optional accessor function.
- Returns:
- {number} the mean of the specified array.
- Parameters:
- {array} array
- an array of objects, or numbers.
- {function} f Optional
- an optional accessor function.
- Returns:
- {number} the median of the specified array.
- Parameters:
- {array} array
- an array of objects, or numbers.
- {function} f Optional
- an optional accessor function.
- Returns:
- {number} the minimum value of the specified array.
- Parameters:
- a
- an element to compare.
- b
- an element to compare.
- Returns:
- {number} negative if a < b; positive if a > b; otherwise 0.
- See:
- Array.sort.
Defined in: Nest.js.
- Parameters:
- {array} array
- an array of elements to nest.
- Returns:
- {pv.Nest} a nest operator for the specified array.
- See:
- pv.Nest
pv.normalize(array, function(d) d.foo)returns a normalized array on the "foo" property. If an accessor function is not specified, the identity function is used. Accessor functions can refer to this.index.
- Parameters:
- {array} array
- an array of objects, or numbers.
- {function} f Optional
- an optional accessor function.
- Returns:
- {number[]} an array of numbers that sums to one.
pv.numerate(["a", "b", "c"])returns {a: 0, b: 1, c: 2}. Note that since JavaScript maps only support string keys, keys must contain strings, or other values that naturally map to distinct string values. Alternatively, an optional accessor function f can be specified to compute the string key for the given element. Accessor functions can refer to this.index.
- Parameters:
- {array} keys
- an array, usually of string keys.
- {function} f Optional
- an optional key function.
- Returns:
- a map from key to index.
.fillStyle(pv.Colors.category10().by(pv.parent))Tthis method is equivalent to function() this.parent.index, but more succinct.
- See:
- pv.Scale
- pv.Mark#index
pv.permute(["a", "b", "c"], [1, 2, 0])returns ["b", "c", "a"]. It is acceptable for the array of indexes to be a different length from the array of elements, and for indexes to be duplicated or omitted. The optional accessor function f can be used to perform a simultaneous mapping of the array elements. Accessor functions can refer to this.index.
- Parameters:
- {array} array
- an array.
- {number[]} indexes
- an array of indexes into array.
- {function} f Optional
- an optional accessor function.
- Returns:
- {array} an array of elements from array; a permutation.
Defined in: Ramp.js.
- Parameters:
- {string} start
- the start color; may be a pv.Color.
- {string} end
- the end color; may be a pv.Color.
- Returns:
- {Function} a color ramp from start to end.
- See:
- pv.Scale.linear
- Parameters:
- min
- {number} minimum value.
- max Optional
- {number} maximum value.
- step Optional
- {numbeR} step value.
The method is modeled after the built-in range method from Python. See the Python documentation for more details.
- Parameters:
- {number} start Optional
- the start value.
- {number} stop
- the stop value.
- {number} step Optional
- the step value.
- Returns:
- {number[]} an array of numbers.
- See:
- Python range
- Parameters:
- {array} a
- an array.
- {number} n Optional
- the number of times to repeat; defaults to two.
- Returns:
- {array} an array that repeats the specified array.
- Parameters:
- a
- an element to compare.
- b
- an element to compare.
- Returns:
- {number} negative if a < b; positive if a > b; otherwise 0.
- See:
- #naturalOrder
Defined in: Color.js.
- Parameters:
- {number} r
- the red channel, an integer in [0,255].
- {number} g
- the green channel, an integer in [0,255].
- {number} b
- the blue channel, an integer in [0,255].
- {number} a Optional
- the alpha channel, a float in [0,1].
- Returns:
- pv.Color.Rgb
The insertion point is defined as the point at which the value would be inserted into the array: the index of the first element greater than the value, or array.length, if all elements in the array are less than the specified value. Note that this guarantees that the return value will be nonnegative if and only if the value is found.
- Parameters:
- {number[]} array
- the array to be searched.
- {number} value
- the value to be searched for.
- {function} f Optional
- an optional key function.
- Returns:
- the index of the search value, if it is contained in the array; otherwise, (-(insertion point) - 1).
- Parameters:
- {array} array
- an array of objects, or numbers.
- {function} f Optional
- an optional accessor function.
- Returns:
- {number} the sum of the specified array.
- Parameters:
- {array[]} arrays
- an array of arrays.
- Returns:
- {array[]} the passed-in array, after transposing the elements.
Defined in: Tree.js.
- Parameters:
- {array} array
- an array from which to construct a tree.
- Returns:
- {pv.Tree} a tree operator for the specified array.
- See:
- pv.Tree
- Parameters:
- map
- an object.
- Returns:
- {array} an array of objects corresponding to the values.
- See:
- #entries
Defined in: Vector.js.
- Parameters:
- {number} x
- the x coordinate.
- {number} y
- the y coordinate.
- Returns:
- {pv.Vector} a vector for the specified coordinates.
- See:
- pv.Vector